<?php

class Lang {
    const LANG_SESSION_KEY = 'lang';
    static private $default_lang = 'en';

    static public function setLang($lang){
        if(!isset($_SESSION)) throw new Exception("Cannot set language: session was not started");
        $_SESSION[self::LANG_SESSION_KEY] = $lang;
    }

    static public function getLang(){
        if(!isset($_SESSION)) throw new Exception("Cannot get language: session was not started");
        if(!isset($_SESSION[self::LANG_SESSION_KEY])) return self::$default_lang;
        return $_SESSION[self::LANG_SESSION_KEY];
    }
} 